<template>
  <div class="shop app_content">
    <div class="flexCenter">
      <!-- 通过 pattern 进行正则校验 -->
<!--      <van-field-->
<!--        style="width: 80%; border-radius: 10px"-->
<!--        v-model="value1"-->
<!--        name="pattern"-->
<!--        placeholder="请输入密码"-->
<!--        :rules="[{ required: true, message: '请输入密码' }]"-->
<!--      />-->
<!--      <div style="margin-top: 10vh">-->
<!--        <van-button-->
<!--          round-->
<!--          block-->
<!--          type="primary"-->
<!--          style="width: 75vw"-->
<!--          @click="start"-->
<!--        >-->
<!--          开始跑批-->
<!--        </van-button>-->
<!--      </div>-->
      <van-field
        style="width: 80%; border-radius: 10px"
        v-model="value2"
        name="pattern"
        placeholder="请输入跑批速度"
        :rules="[{ required: true, message: '请输入跑批速度' }]"
      />
      <div style="margin-top: 10vh">
        <van-button round block type="primary" style="width: 75vw" @click="set">
          设置跑批频率
        </van-button>
      </div>
    </div>
  </div>
</template>

<script setup name="shop">
import { showDialog } from "vant";
const value1 = ref();
const value2 = ref();
const start = () => {
  if (value1.value == "888888") {
    $globalRequest("api/Contron", {}, { method: "post" }).then((res) => {
      showNotify("操作成功");
    });
  } else {
    showNotify("密码错误");
  }
};
const set = () => {
  $globalRequest(
    "api/Cron",
    { cronNum: value2.value },
    { method: "post" }
  ).then((res) => {
    showNotify("操作成功");
  });
};
const showNotify = (message) => {
  showDialog({
    title: "提示",
    message: message,
  });
};
</script>
<style scoped lang="less">
.flexCenter {
  width: 100vw;
  height: 100vh;
  background: #e7eefd;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
</style>
